import { useUser } from '@/stores/user'
import { showConfirmDialog } from 'vant'
import router from '@/router'

export default {
  mounted(el: any) {
    let userStore = useUser()
    el.addEventListener('click', function () {
      if (userStore.token) {
        // 调用加入购物车接口
      } else {
        //没有登录--提示- 对话提示
        showConfirmDialog({
          // title: '标题',
          message: '当前没有登录',
          confirmButtonText: '去登录',
          confirmButtonColor: 'blue'
          // confirm:(){}
        })
          .then(() => {
            // on confirm
            console.log(router)

            console.log('aaa')

            router.push('/login')
          })
          .catch(() => {
            // on cancel
          })
      }
    })
  }
}
